package com.lenovo.agricultureServer.http.action;

import org.json.JSONException;
import org.json.JSONObject;

import com.lenovo.agricultureServer.Serial.SerialportService;
import com.lenovo.agricultureServer.bean.Controller;

public class GetControllerStatusAction extends BaseAction 
{
	public static final String TAG = "getContorllerStatus";
	
	@Override
	protected String jasonPorcess(String param) 
	{
		JSONObject jsonResponse = new JSONObject();
		try 
		{
			jsonResponse.put("WaterPump", SerialportService.getControllerStatusByName(Controller.WATER_PUMP_CONTORL));
			jsonResponse.put("Blower", SerialportService.getControllerStatusByName(Controller.BLOWER_CONTORL));
			jsonResponse.put("Roadlamp", SerialportService.getControllerStatusByName(Controller.ROADLAMP_CONTORL));
			jsonResponse.put("Buzzer", SerialportService.getControllerStatusByName(Controller.BUZZER_CONTORL));
			jsonResponse.put("result", "ok");
			return jsonResponse.toString();
		} 
		catch (JSONException e) 
		{
			e.printStackTrace();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	protected String soapPorcess(String param) {
		//TODO
		return "";
	}

}
